package bb.lanxing.calc.data;

import android.util.Log;

import bb.lanxing.util.CommonUtil;
import org.json.JSONException;
import org.json.JSONObject;

public class PowerData implements Cloneable, RecycleData {
    final private static String TAG = "PowerData";
    private float accePower;
    private float acceleration;
    private float bearing;
    private float grade;
    private float gravPower;
    private boolean isTrainingMode;
    private float power;
    private float pressure;
    private float rollPower;
    private float speed;
    private float temperature;
    private float windDeg;
    private float windPower;
    private float windSpeed;

    public String getPowerExtar() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("windPower", CommonUtil.roundDouble(this.windPower, 2));
            jSONObject.put("rollPower", CommonUtil.roundDouble(this.rollPower, 2));
            jSONObject.put("gravPower", CommonUtil.roundDouble(this.gravPower, 2));
            jSONObject.put("accePower", CommonUtil.roundDouble(this.accePower, 2));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jSONObject.toString();
    }

    protected PowerData clone() {
        try {
            return (PowerData) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public void recycle() {
        this.temperature = 0.0f;
        this.pressure = 0.0f;
        this.speed = 0.0f;
        this.bearing = 0.0f;
        this.acceleration = 0.0f;
        this.windSpeed = 0.0f;
        this.windDeg = 0.0f;
        this.grade = 0.0f;
        this.power = 0.0f;
        this.windPower = 0.0f;
        this.rollPower = 0.0f;
        this.gravPower = 0.0f;
        this.accePower = 0.0f;
    }

    public float getTemperature() {
        return this.temperature;
    }

    public void setTemperature(float temperature) {
        this.temperature = temperature;
    }

    public float getPressure() {
        return this.pressure;
    }

    public void setPressure(float pressure) {
        this.pressure = pressure;
    }

    public float getSpeed() {
        return this.speed;
    }

    public void setSpeed(float speed) {
        this.speed = speed;
    }

    public float getBearing() {
        return this.bearing;
    }

    public void setBearing(float bearing) {
        this.bearing = bearing;
    }

    public float getAcceleration() {
        return this.acceleration;
    }

    public void setAcceleration(float acceleration) {
        this.acceleration = acceleration;
    }

    public float getWindSpeed() {
        return this.windSpeed;
    }

    public void setWindSpeed(float windSpeed) {
        this.windSpeed = windSpeed;
    }

    public float getWindDeg() {
        return this.windDeg;
    }

    public void setWindDeg(float windDeg) {
        this.windDeg = windDeg;
    }

    public float getGrade() {
        return this.grade;
    }

    public void setGrade(float grade) {
        this.grade = grade;
    }

    public float getPower() {
        //Log.d(TAG, "getPower this.power=" + this.power);
        return this.power;
    }

    public void setPower(float power) {
        this.power = power;
        //Log.d(TAG, "setPower this.power=" + this.power);
    }

    public float getWindPower() {
        return this.windPower;
    }

    public void setWindPower(float windPower) {
        this.windPower = windPower;
    }

    public float getRollPower() {
        return this.rollPower;
    }

    public void setRollPower(float rollPower) {
        this.rollPower = rollPower;
    }

    public float getGravPower() {
        return this.gravPower;
    }

    public void setGravPower(float gravPower) {
        this.gravPower = gravPower;
    }

    public float getAccePower() {
        return this.accePower;
    }

    public void setAccePower(float accePower) {
        this.accePower = accePower;
    }

    public boolean isTrainingMode() {
        return this.isTrainingMode;
    }

    public void setTrainingMode(boolean trainingMode) {
        this.isTrainingMode = trainingMode;
    }
}
